import java.io.Serializable;

public class Item implements Serializable {
	private static final long serialVersionUID = 1L;
	int ulen;
	int[] users;
	byte[] votes;

	Item() {
		ulen = 0;
		users = new int[32];
		votes = new byte[32];
	}

	byte getVote(int inputItemID) {
		for (int v = 0; v < ulen; v++) {
			if (users[v] == inputItemID) {
				return votes[v];
			}
		}
		return -1;
	}

	void put(int userID, byte vote) {
		if (ulen > users.length - 1) {
			grow();
		}
		users[ulen] = userID;
		votes[ulen] = vote;
		ulen++;
	}

	void shrink() {
		int[] temp = new int[ulen];
		System.arraycopy(users, 0, temp, 0, ulen);
		users = temp;
		temp = null;

		byte[] tempByte = new byte[ulen];
		System.arraycopy(votes, 0, tempByte, 0, ulen);
		votes = tempByte;
		tempByte = null;
	}

	void grow() {
		int[] temp = new int[ulen * 2];
		System.arraycopy(users, 0, temp, 0, ulen);
		users = temp;
		temp = null;

		byte[] tempByte = new byte[ulen * 2];
		System.arraycopy(votes, 0, tempByte, 0, ulen);
		votes = tempByte;
		tempByte = null;
	}
}
